import { POST, GET } from '@@/utils/http';

/* --======================用户登录======================-- */
/**
 * 获取图形验证码
 */
export const getImgCode = async () => {
  try {
    return await GET('/captcha/createCaptcha', {
      responseType: 'arraybuffer'
    }, {
      needHeader: true
    });
  } catch (e) {}
}

/**
 * 登录
 * @param {{
 *  "passWord": "密码",
    "userCaptcha": "图片验证码",
    "userName": "用户名",
    "uuid": "图片验证码id"
 * }} param 登录参数
 */
export const login = async (param: any) => {
  try {
    return await POST('/mLogin/verify', param, {}, { needResponse: true });
  } catch(e) {}
}

/* --======================用户登录--end======================-- */

/* --======================会议室管理======================-- */
/**
 * 查询所有会议室信息
 * @param sessionKey 
 */
export const getMeetingRooms = async () => {
  try {
    return await POST('/manageMeeting/getAllMeetingRoom');
  } catch (e) {}
}

/**
 * 删除指定会议室
 * @param param 参数对象
 */
export const deleteMeetingRoom = async (param: any) => {
  try {
    return await POST('/manageMeeting/deleteMeetingRoom', param);
  } catch (e) {}
}

/**
 * 添加会议室
 * @param {{
      "meetingRoom": "string",
    }} param 参数对象
 */
export const addMettingRoom = async (param: any) => {
  try {
    return await POST('/manageMeeting/addMeetingRoom', param);
  } catch (e) {}
}

/* --======================会议室管理--end======================-- */

/* --======================意向商家管理======================-- */
/**
 * 查询意向商家列表
 */
export const getBusiness = async () => {
  try {
    return await POST('/manageHotel/getAllHotels');
  } catch (e) {}
}

/**
 * 添加意向商家
 * @param {{
 *  hotelName: ''
 * }} param 参数对象
 */
export const addBusiness = async (param: any) => {
  try {
    return await POST('/manageHotel/addHotel', param);
  } catch (e) {}
}

/**
 * 删除指定id的意向商家
 * @param {{
 *  hotelId: 商家id
 * }} param 参数对象
 */
export const deleteBusiness = async (param: any) => {
  try {
    return await POST('/manageHotel/deleteHotel', param);
  } catch (e) {}
}

/* --======================意向商家管理--end======================-- */

/* --======================用户管理======================-- */
/**
 * 查询所有用户
 */
export const getAllUsers = async () => {
  try {
    return await POST('/manageUser/getAllUsers');
  } catch (e) {}
}

/**
 * 删除指定手机号的用户
 * @param {{
 *  userTel: string
 * }} param 请求参数
 */
export const deleteUser = async (param: any) => {
  try {
    return await POST('/manageUser/deleteUser', param);
  } catch (e) {}
}

/**
 * 修改用户信息
 * @param {{
 *  "userName": "string",
 *  "userTel": "string",
 *  "userType": "1"
 * }} param 请求参数
 */
export const updateUser = async (param: any) => {
  try {
    return await POST('/manageUser/editUser', param);
  } catch (e) {}
}

/* --======================用户管理--end======================-- */